﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<script>
    var SortID = $.request("SortID");
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/ArticleManage/Article/GetGridJson",
            height: $(window).height() - 126,
            colModel: [
                { label: "主键", name: "id", hidden: true, key: true },
                { label: '文章标题', name: 'title', width: 150, align: 'left' },
                { label: '作者', name: 'author', width: 150, align: 'left' },
                { label: '文章内容', name: 'content', width: 350, align: 'left' }               
            ],
            pager: "#gridPager",
            sortname: 'id asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.ajax({
            url: "/ArticleManage/Article/Form",
            async: false,
            success: function (data) {
                location.href = '/ArticleManage/Article/Form';
            }
        });
        
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.ajax({
            url: "/ArticleManage/Article/Form",
            async: false,
            success: function (data) {
                location.href = '/ArticleManage/Article/Form?keyValue=' + keyValue;
            }
        });
    }
    
    function btn_delete() {
        $.deleteForm({
            url: "/ArticleManage/Article/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.ajax({
            url: "/ArticleManage/Article/Details",
            async: false,
            success: function (data) {
                location.href = '/ArticleManage/Article/Details?keyValue=' + keyValue;
            }
        });
    }
    function btn_copyandpaste() {
        $.deleteForm({
            url: "/ArticleManage/Article/copyAndPasteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
        <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建文章</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">@*authorize="yes"*@
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit"  authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改文章</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除文章</a></li>
                <li><a id="NF-Details" authorize="yes" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看文章</a></li>
                @*<li><a id="NF-copyAndPaste"  onclick="btn_copyandpaste()"><i class="fa fa-search-plus"></i>复制粘贴</a></li>*@
            </ul>
            <a href="javascript:;" class="close"></a> 
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="文章标题" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
